-- 公会成员战功奖励
local GuildWarGuildMemberAwardCell = app.mvc.createListViewCell(...)
local IconRender = require("app.widget.renders.IconRender")
--data =
function GuildWarGuildMemberAwardCell.create(node)
    local sprite = GuildWarGuildMemberAwardCell.extend(node or cc.CSLoader:createNode(Res.CSGuildWarGuildMemberAwardCell))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end


function GuildWarGuildMemberAwardCell:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self._icons = {}
    for i =1, 5 do
        local iconRender = IconRender.create(self._ui["Panel/icon_"..i])
        iconRender:setTipEnable(true)
        self._icons[i] = iconRender
    end
    self:refresh()
end

function GuildWarGuildMemberAwardCell:refresh()
    if not self._data then
        return
    end
    local data = self._data
    self._ui.tlt:setString(data.name)
    for k, v in pairs(self._icons) do
        local itemdata = data.awards[k]
        if itemdata then
            v:setVisible(true)
            v:setData(itemdata)
        else
            v:setVisible(false)
        end
    end

    local index = 1
    if self._cellModel then
        index = self._cellModel:getIndex()
    end
    if index == 1 then
        self._ui.img:loadTexture(Res.CSGuildWarMemberRewardIcon1, 1)
    elseif index == 2 then
        cc.SpriteFrameCache:getInstance():addSpriteFrames('ui_resources/team.plist')
        self._ui.img:loadTexture(Res.CSGuildWarMemberRewardIcon2, 1)
    elseif index == 3 then
        cc.SpriteFrameCache:getInstance():addSpriteFrames('ui_resources/team.plist')
        self._ui.img:loadTexture(Res.CSGuildWarMemberRewardIcon3, 1)
    else
        cc.SpriteFrameCache:getInstance():addSpriteFrames('ui_resources/team.plist')
        self._ui.img:loadTexture(Res.CSGuildWarMemberRewardIcon4, 1)
    end
    
end


return GuildWarGuildMemberAwardCell